/*
 * Copyright 2011 Marcin Blazejewski
 *
 * This file is part of Ground0.
 *
 * Ground0 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Ground0 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Ground0. If not, see <http://www.gnu.org/licenses/>.
 *
 */


#ifndef CAMERA_H_
#define CAMERA_H_

#include "stuff.hpp"

class Camera {
protected:
    Vector                  pos, focus, up;
    Vector                  move_to;

public:
    Camera();
    Camera(const Camera &prev);
    Camera(Vector pos, Vector focus);
    virtual ~Camera();
    
    void                    apply();
    virtual void            tick(unsigned int ms);

    Vector&                 get_pos() { return pos; }
    Vector&                 get_focus() { return focus; }
    void                    set_pos(Vector &v);
    void                    set_focus(Vector &v);
};


class ChaseCam : public Camera {
protected:
    class Sim              *target;

public:
    ChaseCam(const Camera &prev, class Sim *object);
    ChaseCam(class Sim *object);

    void                    set_chase_obj(class Sim *s);
    virtual void            tick(unsigned int ms);
};


class RearCam : public Camera {
protected:
    class Stuff*            target;
public:
    RearCam(const Camera &prev, class Stuff *object);
    RearCam(class Stuff *object);

    void                    set_target_obj(class Stuff *s);
    virtual void            tick(unsigned int ms);
};


class TopCam : public Camera {
protected:
    class Stuff*            target;
public:
    TopCam(const Camera &prev, class Stuff *object);
    TopCam(class Stuff *object);

    void                    set_target_obj(class Stuff *s);
    virtual void            tick(unsigned int ms);
};

class FixedCam : public Camera {
protected:
    class Stuff*            target;
public:
    FixedCam(const Camera &prev, class Stuff *object);
    FixedCam(class Stuff *object);

    void                    set_target_obj(class Stuff *s);
    virtual void            tick(unsigned int ms);
};

class OrbitingCam : public Camera {
private:
    const Vector           &target;
    float                   distance;
    float                   elevation, heading;
    bool                    edit;
    int                     x, y;
public:
    OrbitingCam(const class Vector &target,
                const float r=10, const float e=0, 
                const float h=0);
    virtual void            tick(unsigned int ms);
    void                    update();

    void                    set_edit(bool e)    { edit = e; }
    void                    zoom(float dr)      { distance += dr; }
};

#endif
